insert into asm_gecera_anag_utenti_v2
 select distinct '', so.sog_ragsoc,
    '','',
    so.sog_codfis,
    so.sog_pariva,
    so.eletopo_des,
    so.IND_NUM,
    so.IND_SUF,
    so.sog_id,
    '','NODOM','','','',1
    
    from (select s.* from v_soggetto s ,
    (select distinct sog_pariva,sog_codfis,max(sog_id) sog_id from v_soggetto  group by sog_codfis,sog_pariva) s1
    where s.sog_id = s1.sog_id)
        so,
    v_conubifrn ub
    where 
                  ub.sog_idclifin = so.sog_id
                AND ub.az_id = '01'
                AND ub.ver_dtfine = TO_DATE ('31129999', 'ddmmyyyy')
                AND ub.sta_idsys = 2
                and ub.tcon_id ='21'